// Package lvm 调用 Linux 系统对应命令进行操作
package lvm

import "errors"

var (
	ErrEmpty          = errors.New("empty result")
	ErrNotFound       = errors.New("not found")
	ErrExists         = errors.New("already exists")
	ErrNoEnoughSpace  = errors.New("no enough space")
	ErrCanNotReduce   = errors.New("can not reduce space")
	ErrCommand        = errors.New("run command error")
	ErrPVAlreadyInUse = errors.New("physical volume is already in volume group")
)

// VolumeGroup 卷组
//   --- Volume group ---
//  VG Name               yctc
//  System ID
//  Format                lvm2
//  Metadata Areas        1
//  Metadata Sequence No  4
//  VG Access             read/write
//  VG Status             exported/resizable
//  MAX LV                0
//  Cur LV                2
//  Open LV               0
//  Max PV                0
//  Cur PV                1
//  Act PV                1
//  VG Size               <28.85 GiB
//  PE Size               4.00 MiB
//  Total PE              7385
//  Alloc PE / Size       5120 / 20.00 GiB
//  Free  PE / Size       2265 / <8.85 GiB
//  VG UUID               U9XA5c-hCID-h1PZ-g57k-7KDb-chRy-gdCjQC
type VolumeGroup struct {
	Name     string
	Exported bool
	Size     int64
	FreeSize int64
	UUID     string
}

// PhysicalVolume
//   --- Physical volume ---
//  PV Name               /dev/sdc
//  VG Name               yctc (exported)
//  PV Size               28.85 GiB / not usable 4.00 MiB
//  Allocatable           yes
//  PE Size               4.00 MiB
//  Total PE              7385
//  Free PE               2265
//  Allocated PE          5120
//  PV UUID               JUuY3K-1eCJ-s6T5-LW4o-GEjn-PCml-2310bP
type PhysicalVolume struct {
	Name        string
	VGName      string
	Size        int64
	FreeSize    int64
	UUID        string
	MetaData    string
	Allocatable bool
}

// LogicalVolume
//   --- Logical volume ---
//  LV Path                /dev/yctc/lva
//  LV Name                lva
//  VG Name                yctc
//  LV UUID                57xBJM-t3Qx-qkxo-Hha2-pNzL-VNkV-U07VMi
//  LV Write Access        read/write
//  LV Creation host, time 0bc148a5ec18, 1970-01-01 08:11:48 +0800
//  LV Status              available
//  # open                 0
//  LV Size                10.00 GiB
//  Current LE             2560
//  Segments               1
//  Allocation             inherit
//  Read ahead sectors     auto
//  - currently set to     256
//  Block device           254:0
type LogicalVolume struct {
	Name     string
	Path     string
	VGName   string
	UUID     string
	Size     int64
	FreeSize int64
}
